Ext.define('SKJF.view.PENJUALAN.v_penawarandet', {
	extend: 'Ext.grid.Panel',
	requires: ['SKJF.store.s_penawarandet'],
	
	title		: 'penawarandet',
	itemId		: 'Listpenawarandet',
	alias       : 'widget.Listpenawarandet',
	store 		: 's_penawarandet',
	columnLines : true,
	frame		: false,
	
	margin		: 0,
	selectedIndex : -1,
	
	initComponent: function(){		
		this.columns = [
			{
				header: 'NOMOR_QUOTE',
				dataIndex: 'NOMOR_QUOTE'
			},{
				header: 'TGL_DETAIL_QUOTE',
				dataIndex: 'TGL_DETAIL_QUOTE',
				renderer: Ext.util.Format.dateRenderer('d M, Y')
			},{
				header: 'KODE_BARANG',
				dataIndex: 'KODE_BARANG'
			},{
				header: 'NAMA_BARANG',
				dataIndex: 'NAMA_BARANG'
			},{
				header: 'QUANTITY',
				dataIndex: 'QUANTITY'
			},{
				header: 'SATUAN',
				dataIndex: 'SATUAN'
			},{
				header: 'HARGA_SATUAN',
				dataIndex: 'HARGA_SATUAN',
				align: 'right'
				// renderer: function(value){
					// return Ext.util.Format.currency(value, 'Rp ', 2);
				// }
			},{
				header: 'HARGA_TOTAL',
				dataIndex: 'HARGA_TOTAL',
				align: 'right'
				// renderer: function(value){
					// return Ext.util.Format.currency(value, 'Rp ', 2);
				// }
			},{
				header: 'NOTE',
				dataIndex: 'NOTE'
			},{
				header: 'ID',
				dataIndex: 'ID',hidden:true
			}];
		this.dockedItems = [
			Ext.create('Ext.toolbar.Toolbar', {
				items: [{
					xtype: 'fieldcontainer',
					layout: 'hbox',
					defaultType: 'button',
					items: [{
						itemId	: 'btncreate',
						text	: 'Add',
						iconCls	: 'icon-add',
						action	: 'create'
					}, {
						xtype: 'splitter'
					}, {
						itemId	: 'btndelete',
						text	: 'Delete',
						iconCls	: 'icon-remove',
						action	: 'delete',
						disabled: true
					}]
				}, '-', {
					xtype: 'fieldcontainer',
					layout: 'hbox',
					defaultType: 'button',
					items: [{
						itemId	: 'btnprint',
						text	: 'Cetak',
						iconCls	: 'icon-print',
						action	: 'print'
					}]
				}]
			}),
			{
				xtype: 'pagingtoolbar',
				store: 's_penawarandet',
				dock: 'bottom',
				displayInfo: true
			}
		];
		this.callParent(arguments);
		
		this.on('itemclick', this.gridSelection);
		this.getView().on('refresh', this.refreshSelection, this);
	},	
	
	gridSelection: function(me, record, item, index, e, eOpts){
		//me.getSelectionModel().select(index);
		this.selectedIndex = index;
		this.getView().saveScrollState();
	},
	
	refreshSelection: function() {
        this.getSelectionModel().select(this.selectedIndex);   /*Ext.defer(this.setScrollTop, 30, this, [this.getView().scrollState.top]);*/
    }

});